USE ATE
go




IF OBJECT_ID ( 'ATestItem_Insert', 'P' ) IS NOT NULL 
    DROP PROCEDURE ATestItem_Insert;
GO
CREATE PROCEDURE ATestItem_Insert
    @TestItemName nvarchar(50) =null, 
	@SN nvarchar(50) =null,
	@RecordTime nvarchar(50),
	@TestType nvarchar(50),
	@TestValue nvarchar(50)
AS    
    SET NOCOUNT ON;
    if(Len(@TestItemName)>0)
    insert into ATestItem(TestItemName,SN,RecordTime,TestType,TestValue)
	Values(@TestItemName,@SN,CONVERT(DateTime,@RecordTime,120),@TestType,@TestValue);	
GO



IF OBJECT_ID ( 'ATest_Insert', 'P' ) IS NOT NULL 
    DROP PROCEDURE ATest_Insert;
GO
CREATE PROCEDURE ATest_Insert
    @SN nvarchar(50),
	@TypeID nvarchar(50) =null,
	@UserID nvarchar(10),
	@IsPass bit,
	@RecordTime nvarchar(50) output
AS    
    SET NOCOUNT ON;
	set @RecordTime = CONVERT(VARCHAR(30),GETDATE(),120);   	
	insert into ATest(SN,RecordTime,TypeID,TestStep,UserID,IsPass)
	Values(@SN,@RecordTime,@TypeID
		,case when exists(select * from AUnion where PackageProductSN=@SN) then 1 else 0 end
		,@UserID,@IsPass);
GO 





select * from ATest
select * from ATestItem

--delete from ATest
--delete from ATestItem







